//
//  QDUserInfo.m
//  simulateQuickDoctor
//
//  Created by 梁家伟 on 17/3/26.
//  Copyright © 2017年 PipiXia. All rights reserved.
//

#import "QDUserInfo.h"
#import "QDUserDefaultTool.h"


@implementation QDUserInfo

+ (instancetype) defaultUserInfo{
    
    static QDUserInfo* userInfo = nil;
    
    static dispatch_once_t onceToken;
    
    dispatch_once(&onceToken, ^{
        userInfo = [[QDUserInfo alloc]init];
        [userInfo loadInfo];
    });
    return userInfo;
}

- (void)loadInfo{
    
    NSData* data = [QDUserDefaultTool objetForKey:@"userinfo"];
    
    if(data){
        
        QDLoginModel* model = [NSKeyedUnarchiver unarchiveObjectWithData:data];
        
        self.model = model;
        
    }
}

- (void)logOut{
    
    [QDUserDefaultTool qd_removeObjectForKey:@"userinfo"];
    self.model = nil;
}

- (void)logIn{
    NSData* data = [QDUserDefaultTool objetForKey:@"userinfo"];
    
    if(data){
        
        QDLoginModel* model = [NSKeyedUnarchiver unarchiveObjectWithData:data];
        
        self.model = model;
        
    }
}
@end
